<template lang="jade">

div.return-bar
	i.iconfont(@click="back()") &#xe668;
	我的贷款
div.user-center.loan-center.top
	header
		div.top-content
		div.value
			strong {{info.accounts}}
			em 已借金额(元)
		ul.cbox.nav
			li
				b {{info.repay_account_wait}}
				span 待还金额(元)
			li
				b {{info.repay_account_yes}}
				span 已还金额(元)


	div.btnlist.mb10
		a.p_btn_nob(v-link="{ path: '/apply-loan'}") 我要借款
		//a.p_btn_nob 我要借款
		a.g_btn 我要还款(暂未开通)

	ul.s-menu.bottom
		li(v-link="{ path: '/loan/list'}")
			i.iconfont.ft &#xe63c;
			借款项目
			i.iconfont.se &#xe600;



</template>

<script>
import '../../assets/sass/user/loan.scss'
import {c_user_loan} from '../../config/api'

import api from '../../data/api';

export default {

	data () {
		return {
			info:{}
		}
	},


	methods: {
		back(){
			//window.history.back();
			this.$route.router.go('/user');
		},
		async fetch() {
			/* this.$http({url: c_user_loan, method: 'GET'}).then(function (response) {

				var obj = response.data;

				if(!obj.status){
					alert(obj.msg)
					if(obj.code == '10055'){
						sessionStorage.removeItem("login");
						this.$route.router.go('/login?from='+this.$route.path.substring(1))
					}
					return;
				}

				this.info = obj.data
				this.invit_status = this.info.invit_status

			}, function (response) {
					console.log(response)
			}); */

			this.$store.dispatch('setShowLoading', true), this.busy = true;
			var res = await api.user.get_BorrowerInfo();
			this.$store.dispatch('setShowLoading', false), this.busy = false;

			if(!res.status){
				if(res.code == '10055'){
					sessionStorage.removeItem("login");
					this.$route.router.go('/login?from='+this.$route.path.substring(1))
				}
				return;
			}
			this.info = res.data
			this.invit_status = this.info.invit_status
		},

		setMenu: function (next) {
			this.showMenu = !this.showMenu
		},

		goSetUp: function (next) {
			this.$route.router.go('/user-setup?tel='+this.info.phone+'&name='+this.info.realname+'&acno='+this.info.bank_acno)
			//this.$route.router.go('/user-setup');
		}

	},

	route: {
		activate ( transition ) {
			this.fetch();
			transition.next();
			document.title = '我的贷款 - 有喜财富';
		}
	}
}
</script>
